/* This is an example of a situation where you need a single selected record by ID or all of them. */

--Test Case is used to switch between NULL and the CLAIM ID
DECLARE @TestCase VARCHAR(max);

--ClaimID can be either a valid single claimid or NULL for all results
DECLARE @ClaimID VARCHAR(max) = NULL;

--Setup some sample data
DECLARE @TempTable TABLE (ClaimID VARCHAR(max))
INSERT INTO @TempTable VALUES ('A1000')
INSERT INTO @TempTable VALUES ('A2000')
INSERT INTO @TempTable VALUES ('A3000')

--Determine if we should look for a single claimid
IF @ClaimID IS NOT NULL BEGIN SET @TestCase = @ClaimID END

--Retrieve 1 or all
SELECT 
	* 
FROM 
	@TempTable 
WHERE 
	ClaimId =
				CASE 
					WHEN @ClaimID IS NOT NULL THEN @TestCase
					ELSE ClaimID
				END